<template>
  <div class="recruiter-home">
    <!-- 顶部导航栏 -->
    <header class="header">
      <div class="header-content">
        <div class="logo">
          <span class="logo-text">BOSS直聘 -招聘者</span>
        </div>
        
        <nav class="nav-menu">
          <a href="#" class="nav-item active">招聘管理</a>
          <a href="#" class="nav-item">职位管理</a>
          <a href="#" class="nav-item">候选人</a>
          <a href="#" class="nav-item">我的</a>
        </nav>

        <div class="user-info">
          <span class="user-name">{{ user?.username || user?.phone }}</span>
          <button class="logout-btn" @click="handleLogout">退出</button>
        </div>
      </div>
    </header>

    <!-- 欢迎横幅 -->
    <section class="welcome-banner recruiter-banner">
      <div class="banner-content">
        <h1 class="welcome-title">
          欢迎来到BOSS直聘 👔
        </h1>
        <p class="welcome-subtitle">招聘优秀人才，共创美好未来</p>
        
        <!-- 实名认证状态 -->
        <div class="auth-status">
          <div class="status-badge" :class="{ verified: user?.is_realname_authenticated }">
            <span class="status-icon">{{ user?.is_realname_authenticated ? '✅' : '⚠️' }}</span>
            <span class="status-text">
              {{ user?.is_realname_authenticated ? '已实名认证' : '未实名认证' }}
            </span>
          </div>
          <button 
            v-if="!user?.is_realname_authenticated" 
            class="verify-btn" 
            @click="goToVerification"
          >
            <svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
              <path d="M866.9 169.9L527.1 54.1C523 52.7 517.5 52 512 52s-11 .7-15.1 2.1L157.1 169.9c-8.3 2.8-15.1 12.4-15.1 21.2v482.4c0 8.8 5.7 20.4 12.6 25.9L499.3 968c3.5 2.7 8 4.1 12.6 4.1s9.2-1.4 12.6-4.1l344.7-268.6c6.9-5.4 12.6-17 12.6-25.9V191.1c.2-8.8-6.6-18.3-14.9-21.2zM694.5 340.7L481.9 633.4a16.1 16.1 0 0 1-26 0l-126.4-174c-3.8-5.3 0-12.7 6.5-12.7h55.2c5.1 0 10 2.5 13 6.6l64.7 89 150.9-207.8c3-4.1 7.8-6.6 13-6.6H688c6.5.1 10.3 7.5 6.5 12.8z" fill="currentColor"/>
            </svg>
            立即认证
          </button>
        </div>

        <button class="publish-btn">
          <span class="btn-icon">➕</span>
          发布职位
        </button>
      </div>
    </section>

    <!-- 功能卡片 -->
    <section class="features-section">
      <div class="container">
        <h2 class="section-title">招聘服务</h2>
        <div class="features-grid">
          <div class="feature-card">
            <div class="feature-icon" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">
              📋
            </div>
            <h3 class="feature-title">职位发布</h3>
            <p class="feature-desc">快速发布职位，触达海量求职者</p>
          </div>

          <div class="feature-card">
            <div class="feature-icon" style="background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);">
              👥
            </div>
            <h3 class="feature-title">人才库</h3>
            <p class="feature-desc">搜索简历，主动邀约合适人才</p>
          </div>

          <div class="feature-card">
            <div class="feature-icon" style="background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);">
              💬
            </div>
            <h3 class="feature-title">在线沟通</h3>
            <p class="feature-desc">实时与候选人在线交流</p>
          </div>

          <div class="feature-card">
            <div class="feature-icon" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
              📊
            </div>
            <h3 class="feature-title">招聘数据</h3>
            <p class="feature-desc">查看招聘进度和数据分析</p>
          </div>
        </div>
      </div>
    </section>

    <!-- 数据统计 -->
    <section class="stats-section">
      <div class="container">
        <div class="stats-grid">
          <div class="stat-card">
            <div class="stat-number">0</div>
            <div class="stat-label">在招职位</div>
          </div>
          <div class="stat-card">
            <div class="stat-number">0</div>
            <div class="stat-label">收到简历</div>
          </div>
          <div class="stat-card">
            <div class="stat-number">0</div>
            <div class="stat-label">待面试</div>
          </div>
          <div class="stat-card">
            <div class="stat-number">0</div>
            <div class="stat-label">已录用</div>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script setup>
import { computed, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useUserStore } from '../../stores/user'

const router = useRouter()
const route = useRoute()
const userStore = useUserStore()

const user = computed(() => userStore.user)

userStore.restoreUser()

// 处理钉钉登录回调
onMounted(() => {
  const token = route.query.token
  if (token) {
    console.log('🎉 检测到钉钉登录回调token')
    userStore.setTokens(token, '')
    router.replace({ path: '/recruiter' })
  }
})

const handleLogout = () => {
  userStore.logout()
  router.push('/login')
}

// 跳转到实名认证
const goToVerification = () => {
  router.push('/idcard-verification')
}
</script>

<style scoped>
.recruiter-home {
  min-height: 100vh;
  background: #f5f7fa;
}

.header {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: #f5576c;
  letter-spacing: 1px;
}

.nav-menu {
  display: flex;
  gap: 32px;
}

.nav-item {
  color: #666;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: color 0.3s;
}

.nav-item:hover,
.nav-item.active {
  color: #f5576c;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  font-size: 14px;
  color: #333;
  font-weight: 500;
}

.logout-btn {
  padding: 6px 16px;
  background: #f5f7fa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s;
}

.logout-btn:hover {
  background: #ffffff;
  border-color: #f5576c;
  color: #f5576c;
}

.welcome-banner {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  padding: 60px 24px;
  color: white;
}

.banner-content {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.welcome-title {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 16px;
}

.welcome-subtitle {
  font-size: 18px;
  margin-bottom: 24px;
  opacity: 0.9;
}

.auth-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  animation: fadeInUp 0.8s ease-out;
}

.status-badge.verified {
  background: rgba(0, 196, 143, 0.3);
}

.status-icon {
  font-size: 18px;
}

.status-text {
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
}

.verify-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(255, 255, 255, 1);
  border-radius: 20px;
  color: #f5576c;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

.verify-btn:hover {
  background: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.verify-btn svg {
  width: 18px;
  height: 18px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.publish-btn {
  padding: 16px 48px;
  background: white;
  color: #f5576c;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.publish-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.btn-icon {
  font-size: 18px;
}

.features-section {
  padding: 80px 24px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

.section-title {
  font-size: 32px;
  font-weight: 700;
  color: #1a1a1a;
  text-align: center;
  margin-bottom: 48px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.feature-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  transition: all 0.3s;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.feature-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.feature-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.feature-title {
  font-size: 20px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 12px;
}

.feature-desc {
  font-size: 14px;
  color: #666;
  line-height: 1.6;
}

.stats-section {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  padding: 60px 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 32px;
}

.stat-card {
  text-align: center;
  color: #ffffff;
}

.stat-number {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 16px;
  opacity: 0.9;
}

@media (max-width: 768px) {
  .nav-menu {
    display: none;
  }
  
  .welcome-title {
    font-size: 32px;
  }
}
</style>

